package com.bsoft.exchange.controller.report;

import com.bsoft.exchange.domain.*;
import com.bsoft.exchange.pojo.CheckReportParam;
import com.bsoft.exchange.pojo.InspectionListParam;
import com.bsoft.exchange.response.ResponseEntity;
import com.bsoft.exchange.service.InspectionReportService;
import com.bsoft.exchange.util.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;


@RestController
public class  ReportController {
    @Value("${report_url}")
    private String url;

    @Autowired
    private InspectionReportService inspectionReportService;

    /**
     * @return
     */
    @RequestMapping(value = "inspectionreport/listInspectionReport",method = RequestMethod.POST,produces = "application/json")
    public ResponseEntity<ListInspectionReportResponse> inspectionList(@RequestBody InspectionListParam inspectionListParam) {
        ResponseEntity<ListInspectionReportResponse> responseEntity = new ResponseEntity<>();
        inspectionListParam.setAuthorOrganizationId("46821120-9");
        ListInspectionReportResponse listInspectionReportResponse = inspectionReportService.inspectionList(inspectionListParam, url);
        responseEntity.setData(listInspectionReportResponse);
        responseEntity.setCode(Constant.successResponse);
        responseEntity.setMessage("查询成功！");

        return responseEntity;
    }

    @RequestMapping(value = "checkreport/listCheckReport",method = RequestMethod.POST,produces = "application/json")
    public ResponseEntity<ListExamReportResponse> listExamReport(@RequestBody CheckReportParam checkReportParam){
        ResponseEntity<ListExamReportResponse> responseEntity = new ResponseEntity<>();
        checkReportParam.setHospitalCode("46821120-9");
        ListExamReportResponse listExamReportResponse = inspectionReportService.listExamReport(checkReportParam, url);
        if(listExamReportResponse == null) {
            responseEntity.setMessage("暂无数据！");
        } else {
            responseEntity.setData(listExamReportResponse);
            responseEntity.setMessage("查询成功！");
        }
        responseEntity.setCode(Constant.successResponse);
        return responseEntity;
    }
}
